package com.xing.crm.web.controller;

import com.xing.crm.pojo.PageResult;
import com.xing.crm.pojo.WebUser;
import com.xing.crm.service.WebUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/** 用户管理
 * @author Mr.L
 * @version V1.0
 * @date 2021年07月29日 17:12
 */
@RequestMapping("/webUser")
@Controller
public class WebUserController {
	
	@Resource
	private WebUserService webUserService;
	
	/**
	 * 功能描述: 列表页
	 * @date 2021/8/13 10:26
	 * @param 
	 * @return java.lang.String
	 * */
	@RequestMapping("/listPage")
	public String listPage() {
		return "admin/user/list";
	}
	
	/**
	 * 功能描述: 用户列表
	 * @date 2021/8/13 10:26
	 * @param page
	 * @param limit
	 * @param webUser
	 * @return com.xing.crm.model.PageResult<com.xing.crm.model.WebUser>
	 * */
	@ResponseBody
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public PageResult<WebUser> list(@RequestParam(required = false, defaultValue = "1") int page,
			@RequestParam(required = false, defaultValue = "10") int limit, WebUser webUser)
	{
		
		return webUserService.list(webUser, page, limit);
	}
	
	/**
	 * 功能描述: 更新信息
	 * @date 2021/8/13 10:25
	 * @param webUser
	 * @return java.util.Map<java.lang.String,java.lang.Object>
	 * */
	@ResponseBody
	@RequestMapping(value = "/edit", method = RequestMethod.POST)
	public Map<String, Object> edit(WebUser webUser) {
	
		return webUserService.edit(webUser);
	}
	
	/**
	 * 功能描述: 修改密码
	 * @date 2021/8/13 10:25
	 * @param webUser
	 * @return java.util.Map<java.lang.String,java.lang.Object>
	 * */
	@ResponseBody
	@RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
	public Map<String, Object> updatePwd(WebUser webUser) {
		
		return webUserService.updatePwd(webUser);
	}
	
	/**
	 * 功能描述: 删除用户

	 * @date 2021/8/13 10:24
	 * @param id
	 * @return java.util.Map<java.lang.String,java.lang.Object>
	 * */
	@ResponseBody
	@RequestMapping("/delete")
	public Map<String, Object> delete(Integer id) {
	
		return webUserService.delete(id);
	}
	
	/**
	 * 功能描述: 任命店长

	 * @date 2021/8/13 10:22
	 * @param sid
	 * @param uid
	 * @return java.util.Map<java.lang.String,java.lang.Object>
	 * */
	@ResponseBody
	@RequestMapping(value = "/appoint", method = RequestMethod.POST)
	public Map<String, Object> appoint(Integer sid, Integer uid) {
		
		return webUserService.appointShopManager(sid, uid);
	}
	
	/**
	 * 功能描述: 获取无权限用户

	 * @date 2021/8/13 10:23
	 * @param
	 * @return java.util.Map<java.lang.String,java.lang.Object>
	 * */
	@ResponseBody
	@RequestMapping(value = "/getUsers", method = RequestMethod.GET)
	public Map<String, Object> getUsers() {
	
		return webUserService.getUsers();
	}
}
